package com.chaosj.webmagic.dto;

public enum SearchEnums {
    /**
     *
     */
    HOME(0,"https://www.gushiwen.cn/","https://www.gushiwen.cn/","首页"),
    /**
     *
     */
    SHI_WEN(1,"https://so.gushiwen.cn/shiwens/default.aspx?page=%s&tstr=&astr=&cstr=&xstr=","https://www.gushiwen.cn/","诗文"),
    /**
     *
     */
    MING_JU(2,"https://so.gushiwen.cn/mingjus/default.aspx?page=%s&tstr=&astr=&cstr=&xstr=","https://www.gushiwen.cn/","名句"),
    /**
     *
     */
    ZUO_ZHE(3,"https://so.gushiwen.cn/authors/default.aspx?p=%s&c=","https://www.gushiwen.cn/","作者"),
    /**
     *
     */
    GU_WEN(4,"https://so.gushiwen.cn/guwen/default.aspx?p=1&type=","https://www.gushiwen.cn/","古籍"),
    /**
     *
     */
    LEXICON(5, "http://www.idiomschina.com/search/%s/%s.html","http://www.idiomschina.com/","词库"),
    /**
     *
     */
    POEM_CHINA( 6, "https://www.poemschina.com/search?key=%s","https://www.poemschina.com/","美文"),
    ;
    private int type;
    private String target;
    private String label;
    private String domain;

    public int getType() {
        return type;
    }

    public String getTarget() {
        return target;
    }

    public String getLabel() {
        return label;
    }

    public String getDomain(){
        return domain;
    }

    SearchEnums(int type, String target, String domain, String label) {
        this.type = type;
        this.target = target;
        this.domain = domain;
        this.label = label;
    }

    public static SearchEnums getInstance(int type){
        for ( SearchEnums instance : SearchEnums.values() ) {
            if( instance.type == type ){
                return instance;
            }
        }
        return HOME;
    }
}
